package com.fortune.rainshine.common.utils;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.springframework.stereotype.Service;

/**  
* @ClassName: PIcUtils  
* @Description: TODO(图片转换)  
* @author 张鑫
* @phone 17561783855
* @date 2019年3月30日  
*    
*/
@Service
public class PIcUtils {

//    public byte[] quality(byte[] srcImgData, float scale) throws IOException {
//        BufferedImage bi = ImageIO.read(new ByteArrayInputStream(srcImgData));
//        int widthOld = (int) bi.getWidth(); // 源图宽度
//
////        if(widthOld <= 880 && widthOld >= 300) {
////        	scale = 0.5f;
////        }else if(widthOld < 300) {
////        	scale = 1f;
////        }
//        scale = 1f;
//        int width = (int) (bi.getWidth() * scale); // 源图宽度
//        int height = (int) (bi.getHeight() * scale); // 源图高度
//
//        Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
//        BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
//
//        Graphics g = tag.getGraphics();
//        g.setColor(Color.RED);
//        g.drawImage(image, 0, 0, null); // 绘制处理后的图
//        g.dispose();
//
//        java.io.ByteArrayOutputStream bOut = new java.io.ByteArrayOutputStream();
//        ImageIO.write(tag, "JPEG", bOut);
//
//        return bOut.toByteArray();
//    }
}
